using MicroMsg.Common.Event;
using MicroMsg.Manager;
using MicroMsg.Plugin.QQInfo.Scene;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.Storage;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class ViewQQFriends : BasePage
	{
		private EventWatcher mQQGroupSuccessWatcher;
		private EventWatcher mQQGroupFailWatcher;
		private NetSceneQQInfo mNetSceneQQInfo;
		private string strObj;
		private int noGroupView = 1;
		private List<QGroup> list;
		internal Grid LayoutRoot;
		internal panelTitle2Line panelTitle;
		internal Grid ContentPanel;
		internal ViewFlipper ListViewFlipper;
		internal ListBox GroupList;
		internal StackPanel panelNoMobileContact;
		internal Image imgNoContact;
		internal TextBlock txtNoContactNote;
		private bool _contentLoaded;
		public ViewQQFriends()
		{
			this.InitializeComponent();
			base.add_Loaded(new RoutedEventHandler(this.ViewQQFriends_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.ViewQQFriends_Unloaded));
		}
		private void ViewQQFriends_Loaded(object sender, RoutedEventArgs e)
		{
			this.mQQGroupFailWatcher = new EventWatcher(this, this, new EventHandlerDelegate(this.on_Get_QQGroupFail_EventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_QQGROUP_ERR, this.mQQGroupFailWatcher);
			this.mQQGroupSuccessWatcher = new EventWatcher(this, this, new EventHandlerDelegate(this.on_Get_QQGroupSuccess_EventHandler));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_QQGROUP_SUCCESS, this.mQQGroupSuccessWatcher);
			this.list = QQInfoService.getInstance().GetQQGroupList(ref this.mNetSceneQQInfo);
			if (this.list != null && this.list.get_Count() != 0)
			{
				this.GroupList.set_ItemsSource(new ObservableCollection<QGroup>(this.list));
				this.hideProgressCover();
			}
		}
		private void ViewQQFriends_Unloaded(object sender, RoutedEventArgs e)
		{
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_QQGROUP_ERR, this.mQQGroupFailWatcher);
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_QQGROUP_SUCCESS, this.mQQGroupSuccessWatcher);
			this.mNetSceneQQInfo.cancel();
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (object_0 != null && Enumerable.Count<object>(object_0) == 1)
			{
				this.strObj = (object_0[0] as string);
				if (this.strObj == "QQOfflineMsgPulgin")
				{
					ServiceCenter.statReportMgr.addStatItem(enKVStatKey.MM_QQMSG_CLICK, "1");
				}
			}
			this.showProgressCover(strings.QQFriend_GetInfo);
		}
		private void on_Get_QQGroupSuccess_EventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.hideProgressCover();
			this.list = StorageMgr.qgroup.getList();
			if (this.list != null && this.list.get_Count() != 0)
			{
				this.GroupList.set_ItemsSource(new ObservableCollection<QGroup>(this.list));
				return;
			}
			this.ListViewFlipper.ShowView(this.noGroupView);
		}
		private void on_Get_QQGroupFail_EventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.hideProgressCover();
			if (this.list == null || this.list.get_Count() == 0)
			{
				MMMessageBox mMMessageBox = MMMessageBox.Show("", strings.QQFriend_GetInfo_Err, false, strings.COM_Retry, strings.COM_Return);
				mMMessageBox.ReturnEvent = new DlgReturnEvent(this.OnGetDataErrorHandler);
			}
		}
		private void GroupListItem_ItemClick(object sender, object object_0)
		{
			QGroup qGroup = object_0 as QGroup;
			base.GoToPage("/Source/Plugin/Common/QQInfo/UI/ViewQQSingleGroupDetail.xaml", new object[]
			{
				qGroup,
				this.strObj
			}, false);
		}
		public void OnGetDataErrorHandler(DlgReturnEventArg dlgReturnEventArg_0)
		{
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				this.showProgressCover(strings.QQFriend_GetInfo);
				QQInfoService.getInstance().GetQQGroupList(ref this.mNetSceneQQInfo);
				return;
			case 1:
				if (base.get_NavigationService().get_CanGoBack())
				{
					base.get_NavigationService().GoBack();
				}
				return;
			default:
				return;
			}
		}
		private void showProgressCover(string strCoverTitle)
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, strCoverTitle, null, false, false, null);
		}
		private void hideProgressCover()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Common/QQInfo/UI/ViewQQGroups.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.ListViewFlipper = (ViewFlipper)base.FindName("ListViewFlipper");
			this.GroupList = (ListBox)base.FindName("GroupList");
			this.panelNoMobileContact = (StackPanel)base.FindName("panelNoMobileContact");
			this.imgNoContact = (Image)base.FindName("imgNoContact");
			this.txtNoContactNote = (TextBlock)base.FindName("txtNoContactNote");
		}
	}
}
